<%@page import="com.core.util.DspUtil"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="../common/header.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<%
   String currYearMonth = DspUtil.getCurrentYearMonth();
%>
<title>DSP</title>
<%@include file="../common/link.jsp"%>
<script src="javascript?type=selectTags"></script>
<script src="javascript?type=Com"></script>
<script type="text/javascript" src="javascript?type=item"></script>
<script>
var config = {
		url : 'insure_results',query_url : 'insure_results_subs_query'
	}
	
var colModel = [
			{
				title : "计算年月",
				field : 'yearMonth',
				width : 50
			}, {
				title : '员工',
				field : 'empName',
				width : 90,
				align : 'left'
			}, {
				title : '户口性质',
				field : 'hukou',
				width : 40,
				align : 'center',
				formatter: function(cell , row , dataIndex){
					return selectTags["hukou_"+cell];
				}
			}, {
				title : '公司',
				field : 'company',
				width : 80,
				formatter: function(cell , row , dataIndex){
					var val = '';
					for ( var i = 0; i < Com.length; i++) {
						if (cell == Com[i].id) {
							val = Com[i].value;
							break;
						}
					}
					return val;
				}
			}];
	function update(data) {
		 
	}
	function init(){
		
	}
</script>
</head>
<body onload="init();">
	<form id="qForm">
		<table width="60%" cellspacing="3" cellpadding="3"
			bordercolor="#DEDEDC" border="0" id="q-form" >
			<tr>
				<th width="15%" class="td_left" valign="middle">计算年月:</th>
				<td width="20%"><input type="text" name="q_yearMonth" id="q_yearMonth" value='<%=currYearMonth%>' />
				</td>
				<th width="15%" class="td_left" valign="middle">员工:</th>
				<td width="20%"><input type="text" name="q_empName" id="q_empName" />
				</td>
			</tr>
			<tr>
				<th width="15%" class="td_left" valign="middle">户口性质:</th>
				<td><dsp:selectTag htmlId="q_hukou" tagId="hukou"  isAll="true" />
				</td>
				<th class="td_left" valign="middle">公司:</th>
				<td><select name="q_company" id="q_company"></select>
				   <script>
				   	var com = "<option value=''>请选择公司</option>";
				   	$.each(Com,function(i, obj) {
				   		if(obj.id != '') {
				   			com += "<option value='"+ obj.id+"'>"+ obj.value+"</option>";
				   		}
				   	});
				   	$("#q_company").append(com);
				   </script>
				</td>
			</tr>
		</table>
		</form>
	<div id="dialog_div" class="easyui-window" title="社保明细记录"
		collapsible="false" minimizable="false" maximizable="false"
		icon="icon-save"
		style="width: 310px; height: 310px; left: 200px; top: 100px; padding: 5px; background: #fafafa;">
		<div class="easyui-layout" fit="true">
			<div region="center" border="false"
				style="padding: 10px; background: #fff; border: 1px solid #ccc;">
				<form action="" id="form1">
					<input type="hidden" name="id" id="id"value="" />
					<table width="100%" cellspacing="3" cellpadding="3"
						bordercolor="#DEDEDC" border="0" id="id-form">
						<tr>
							<th class="td_right" valign="middle"><span
								style="color: #FF0000">*</span>身份证:</th>
							<td><input type="text" name="empidn" id="empidn" size="25"
								jval="{valid:function(val){ return checkIempidn(val); }}"
								maxlength="18" /></td>
							<th class="td_right" valign="middle"><span
								style="color: #FF0000">*</span>性别:</th>
							<td><dsp:radioTag htmlId="sex" htmlValue="" tagId="sex"
									oAction="" />
							</td>
						</tr>
						<tr>
							<th class="td_right" valign="middle"><span
								style="color: #FF0000">*</span>身份证:</th>
							<td><input type="text" name="empidn" id="empidn" size="25"
								jval="{valid:function(val){ return checkIempidn(val); }}"
								maxlength="18" /></td>
							<th class="td_right" valign="middle"><span
								style="color: #FF0000">*</span>性别:</th>
							<td><dsp:radioTag htmlId="sex" htmlValue="" tagId="sex"
									oAction="" />
							</td>
						</tr>

					</table>
				</form>
			</div>
		</div>
	</div>
	<script>
		$(function() {
			DSP.open(false, 310, 600, "");
			//监听查询输入框事件
			$("#qForm input").keyup(function(event){
				var e = event || window.event; //浏览器兼容
				if(e.keyCode == 13){ 
					 DSP.grid.query();
				}
			});
			$("#qForm select").change(function(){
				DSP.grid.query();
			});
			$('#xDataGrid').datagrid({
				title:"社保结果",
				url : config.url + '_list',
				height : 'auto',
				width : 650,
				fitColumns : true,
				method:'POST',
				nowrap : false,
				striped : true,
				collapsible : true,
				singleSelect : true,
				pageSize : 15,
				pageList : [15],// 可以设置每页记录条数的列表
				queryParams : {q_yearMonth:'<%=currYearMonth%>'},
				idField : 'id',
				frozenColumns : [[{
					field : 'ck',
					checkbox : true
				}]],
				columns : [ colModel ],
				pagination : true,
				rownumbers : true,
				onClickRow:function(rowIndex , rowData){
					$("#xDataGridSub").datagrid('options').queryParams = {qtype:'mainId',query:rowData.id}; //queryparams;
					$("#xDataGridSub").datagrid('clearSelections');
					$("#xDataGridSub").datagrid('reload');
				},
				toolbar : [{
					id : 'download_in',
					text : '导出社保资料',
					iconCls : 'icon-undo',
					handler : function() {
						var form = $("#qForm").serializeObject();
						DSP.Server(config.url+'_download' , form ,function(json){
							window.location = 'FileDownload.jsp?FName='+json.path;
						},DSP.contentType);
					}
				}]
			});
			$("#xDataGridSub").datagrid({
				title:'社保明细',
				height: 'auto',
				width:300,
				fitColumns : true, method:'POST',nowrap :false,
				url : config.query_url,queryParams : {qtype:'mainId' , query:''},
				idField : 'id', 
				rownumbers : true,showFooter:true,
				columns : [
				 	[{
						title : '社保项目',
						field : 'insureItem',
						width : 90,
						align : 'left',
						formatter: function(cell , row , dataIndex){
							if (cell == -1) {
								return "个人汇总";
							} else if (cell == -2){
								return "公司汇总";
							} else  
								return item[cell];
						}
					},{
						title : '金额',
						field : 'insureMoney',
						width : 90,
						align : 'right',
						formatter:function(cell , row ,dataIndex){
							if(row.insureItem == -1 || row.insureItem == -2){
								return '<font color="red">'+cell+'</font>';
							} else {
								return cell;
							}
						}
					},{
						title : '社保类型',
						field : 'insureType',
						width : 90,
						align : 'left',
						formatter: function(cell , row , dataIndex){
							return cell == 1 ? "个人" :  cell == 2 ? "公司":"";
						}
					}]          
				 ],
				 toolbar:[]
			});
		});
	</script>
	<table>
		<tr>
			<td valign="top">
				<table id="xDataGrid"></table>
			</td>
			<td valign="top">
				<table id="xDataGridSub"></table>
			</td>
	</tr>
	</table>
</body>
</html>
